package com.editso.haier.entity;

import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;

/**
 * vip信息
 * */
@Table
@Entity
@Getter
@Setter
@NoArgsConstructor
public class Vip {

    @Id
    @Column(nullable = false, unique = true)
    private Integer type;

    @Column(nullable = false, unique = true)
    private String name;

    @Column(nullable = false)
    private String description;

    @Column(nullable = false, insertable = false, columnDefinition = "datetime default now()")
    private Timestamp crateDate;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable( name = "vip_user",
                joinColumns = @JoinColumn(name = "vip_id"),
                inverseJoinColumns = @JoinColumn(name = "user_id"))
    private Set<User> users;


    public Vip(Integer type, String name, String description) {
        this.type = type;
        this.name = name;
        this.description = description;
    }
}
